package com.example.javafx.按钮;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {

        primaryStage.setTitle("Hello Word");
        Button btn = new Button();
        btn.setText("Say 'Hello word'");
        btn.setOnAction(event -> {
            Button button = (Button)event.getSource();
            System.out.println(button.getText());
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root,300,250));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
